
package de.carcophan.jimdb.ejb.entites.service;

import de.carcophan.jimdb.ejb.entites.User;
import de.carcophan.jimdb.ejb.entites.UserMovies;
import java.util.List;
import java.util.Set;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;


@Stateless
public class UserFacade extends AbstractFacade<User> {

    @PersistenceContext(unitName = "jimdb-warPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public UserFacade() {
        super(User.class);
    }

    public User findByLoginId(String authenticatedUser) {
        User u = (User) em.createQuery("select u from User u where u.loginId=:loginId").setParameter("loginId", authenticatedUser).getSingleResult();
        return u;
    }

    public List<UserMovies> getMoviesForUser(User u,Set<String> movieIds){
//        em.createQuery("select m from Movie m where ")
        return null;
    }
}
